package util

import (
	"fmt"
	"io"
	"net/http"
)

func HttpGet(url string) (string, error) {
	response, err := http.Get(url)
	if err != nil {
		fmt.Printf("访问%s错误：%s", url, err)
		return "", err
	}
	body := response.Body
	defer func(body io.ReadCloser) {
		err := body.Close()
		if err != nil {
			fmt.Printf("Body关闭错误：%s", err)
			return
		}
	}(body)
	result := ReadCloserToString(body)
	return result, nil
}
